from pydantic import BaseModel, EmailStr
from typing import Optional
from sqlalchemy import Column, Integer, String
from app.repository.base import Base

# SQLAlchemy Model
class UserEntity(Base):
    __tablename__ = "sys_user"

    id = Column(Integer, primary_key=True, index=True)
    row_index = Column(Integer, nullable=False)
    name = Column(String(50), nullable=False)
    email = Column(String(100), unique=True, nullable=False)

# Pydantic Models
class UserBase(BaseModel):
    name: str
    email: str

class UserCreate(UserBase):
    pass

class UserUpdate(BaseModel):
    name: Optional[str] = None
    email: Optional[str] = None

class UserResponse(UserBase):
    id: int
    row_index: int

    class Config:
        orm_mode = True
